<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Arduino MIDI File Parser: src/MidiFileParserMultiTrack.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Arduino MIDI File Parser
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">MidiFileParserMultiTrack.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="MidiFileParser_8h.html">MidiFileParser.h</a>&quot;</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include &lt;iterator&gt;</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &lt;list&gt;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160; </div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="keyword">namespace </span>midi {</div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160; </div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="keyword">enum</span> ProcessingStatus { Inserting, Parsing, EndOfData };</div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160; </div>
<div class="line"><a name="l00015"></a><span class="lineno"><a class="line" href="classmidi_1_1multichannel__segment__tracks.html">   15</a></span>&#160;<span class="keyword">class </span><a class="code" href="classmidi_1_1multichannel__segment__tracks.html">multichannel_segment_tracks</a> {</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00018"></a><span class="lineno"><a class="line" href="classmidi_1_1multichannel__segment__tracks.html#a119d4fc00378871d2bef72a88a572935">   18</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a119d4fc00378871d2bef72a88a572935">add</a>(<span class="keywordtype">int</span> track, <a class="code" href="structmidi_1_1midi__time__event.html">midi_time_event</a> event) {</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;    <span class="comment">// add new track</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;    addTrack(track);</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;    <span class="comment">// add event</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;    <span class="keywordflow">if</span> (event.status!=0){</div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;      tracks[track].push_back(event);</div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    }</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;  }</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160; </div>
<div class="line"><a name="l00028"></a><span class="lineno"><a class="line" href="classmidi_1_1multichannel__segment__tracks.html#adc37815ca340a51bdba2cff65139dc20">   28</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classmidi_1_1multichannel__segment__tracks.html#adc37815ca340a51bdba2cff65139dc20">trackCount</a>() { <span class="keywordflow">return</span> tracks.size(); }</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160; </div>
<div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="classmidi_1_1multichannel__segment__tracks.html#a79722815460ae3f98162837e93adcfc6">   31</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a79722815460ae3f98162837e93adcfc6">begin</a>() {</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;    <span class="comment">// set iterators to first element</span></div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;    process_status = EndOfData;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> track = 0; track &lt; tracks.size(); track++) {</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;      <span class="keywordflow">if</span> (iterators.size() &lt; track + 1) {</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;        iterators.push_back(tracks[track].<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a79722815460ae3f98162837e93adcfc6">begin</a>());</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;      } <span class="keywordflow">else</span> {</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;        iterators[track] = tracks[track].begin();</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;      }</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;      <span class="comment">// check if there is any ndata</span></div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;      <span class="keywordflow">if</span> (iterators[0] != tracks[0].<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a0862757999f906a2bfd71881257747a8">end</a>()) {</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;        process_status = Parsing;</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;      }</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    }</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;  }</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160; </div>
<div class="line"><a name="l00048"></a><span class="lineno"><a class="line" href="classmidi_1_1multichannel__segment__tracks.html#abd2d16ad792d4d417abacfadb167d56b">   48</a></span>&#160;  <a class="code" href="structmidi_1_1midi__time__event.html">midi_time_event</a> &amp;<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#abd2d16ad792d4d417abacfadb167d56b">nextEvent</a>() {</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    <span class="keywordflow">if</span> (process_status == Inserting) {</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;      <span class="keywordflow">return</span> no_data;</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    }</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160; </div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;    <span class="keywordtype">int</span> min_idx = 0;</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    process_status = EndOfData;</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    <span class="comment">// find entry with min time</span></div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    uint64_t min_time = 0xFFFFFFFFFFFFFFFF;</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; <a class="code" href="classmidi_1_1multichannel__segment__tracks.html#adc37815ca340a51bdba2cff65139dc20">trackCount</a>(); j++) {</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;      <span class="keywordflow">if</span> (iterators[j] != tracks[j].<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a0862757999f906a2bfd71881257747a8">end</a>() &amp;&amp;</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;          (*iterators[j]).time_ms &lt; min_time) {</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;        min_idx = j;</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;        process_status = Parsing;</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;      }</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    }</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160; </div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    <span class="keywordflow">if</span> (process_status == EndOfData) {</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;      <span class="keywordflow">return</span> no_data;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    }</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160; </div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    <span class="comment">// increment iterator and return result</span></div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    <a class="code" href="structmidi_1_1midi__time__event.html">midi_time_event</a> *p_result = &amp;(*iterators[min_idx]);</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;    iterators[min_idx]++;</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    <span class="keywordflow">return</span> *p_result;</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;  }</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160; </div>
<div class="line"><a name="l00076"></a><span class="lineno"><a class="line" href="classmidi_1_1multichannel__segment__tracks.html#a61c06ef313591f12494db1e1b81748a1">   76</a></span>&#160;  <span class="keywordtype">size_t</span> <a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a61c06ef313591f12494db1e1b81748a1">size</a>() {</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;    <span class="keywordtype">size_t</span> result = 0;</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = 0; j &lt; <a class="code" href="classmidi_1_1multichannel__segment__tracks.html#adc37815ca340a51bdba2cff65139dc20">trackCount</a>(); j++) {</div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;      result += tracks[j].size();</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    }</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    <span class="keywordflow">return</span> result;</div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;  }</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160; </div>
<div class="line"><a name="l00085"></a><span class="lineno"><a class="line" href="classmidi_1_1multichannel__segment__tracks.html#a885bc5c9546339e4c60d74c6c4f9ac56">   85</a></span>&#160;  <span class="keywordtype">bool</span> <a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a885bc5c9546339e4c60d74c6c4f9ac56">isEmpty</a>() { <span class="keywordflow">return</span> <a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a61c06ef313591f12494db1e1b81748a1">size</a>() == 0; }</div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160; </div>
<div class="line"><a name="l00088"></a><span class="lineno"><a class="line" href="classmidi_1_1multichannel__segment__tracks.html#afd3ff3d9ec131ac20c6c0c5ce46a777a">   88</a></span>&#160;  uint64_t <a class="code" href="classmidi_1_1multichannel__segment__tracks.html#afd3ff3d9ec131ac20c6c0c5ce46a777a">lastTime</a>(<span class="keywordtype">int</span> track) {</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    addTrack(track);</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    <span class="keyword">auto</span> &amp;events = tracks[track];</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    <span class="keywordflow">if</span> (events.empty())</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;      <span class="keywordflow">return</span> 0;</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    <span class="keywordflow">return</span> events.back().time_ms;</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;  }</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160; </div>
<div class="line"><a name="l00097"></a><span class="lineno"><a class="line" href="classmidi_1_1multichannel__segment__tracks.html#a0862757999f906a2bfd71881257747a8">   97</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a0862757999f906a2bfd71881257747a8">end</a>() {</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;    tracks.clear();</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    iterators.clear();</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;  }</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160; </div>
<div class="line"><a name="l00103"></a><span class="lineno"><a class="line" href="classmidi_1_1multichannel__segment__tracks.html#a36e682a113fbf286e3833c1b33aba26d">  103</a></span>&#160;  ProcessingStatus <a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a36e682a113fbf286e3833c1b33aba26d">status</a>() { <span class="keywordflow">return</span> process_status; }</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160; </div>
<div class="line"><a name="l00106"></a><span class="lineno"><a class="line" href="classmidi_1_1multichannel__segment__tracks.html#aa0208bedf8eabeab38747a41e94fc29b">  106</a></span>&#160;  <a class="code" href="structmidi_1_1midi__time__event.html">midi_time_event</a> &amp;<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#aa0208bedf8eabeab38747a41e94fc29b">getNoDataEvent</a>() { <span class="keywordflow">return</span> no_data; }</div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160; </div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;<span class="keyword">protected</span>:</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;  std::vector&lt;std::list&lt;midi_time_event&gt;&gt; tracks;</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;  std::vector&lt;std::list&lt;midi_time_event&gt;::iterator&gt; iterators;</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;  <a class="code" href="structmidi_1_1midi__time__event.html">midi_time_event</a> no_data;</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;  ProcessingStatus process_status = Inserting;</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160; </div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;  <span class="keywordtype">void</span> addTrack(<span class="keywordtype">int</span> track) {</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    <span class="keywordflow">if</span> (track &gt;= tracks.size()) {</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;      std::list&lt;midi_time_event&gt; event_list;</div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;      tracks.push_back(event_list);</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    }</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;  }</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;};</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160; </div>
<div class="line"><a name="l00130"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html">  130</a></span>&#160;<span class="keyword">class </span><a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html">MidiFileParserMultiTrack</a> : <span class="keyword">public</span> <a class="code" href="classmidi_1_1Print.html">Print</a> {</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00133"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#af71bf056c87c4b20f92e61f1864c0fda">  133</a></span>&#160;  <span class="keywordtype">bool</span> <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#af71bf056c87c4b20f92e61f1864c0fda">begin</a>(<span class="keywordtype">bool</span> log = <span class="keyword">true</span>, <span class="keywordtype">int</span> bufferSize = MIDI_BUFFER_SIZE) {</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#af23129775e877eed69220c3709562d86">restart</a>();</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;    <span class="keywordflow">return</span> parser.<a class="code" href="classmidi_1_1MidiFileParser.html#aabf9f00c6bb20006a33690ce1ae27dd6">begin</a>(log, bufferSize);</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;  }</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160; </div>
<div class="line"><a name="l00139"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#af23129775e877eed69220c3709562d86">  139</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#af23129775e877eed69220c3709562d86">restart</a>() {</div>
<div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;    is_iterators_available = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    start_time = millis();</div>
<div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;    p_current_state = <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;  }</div>
<div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160; </div>
<div class="line"><a name="l00146"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#a76afb244cc53b394e777ba395d49d88e">  146</a></span>&#160;  <span class="keywordtype">size_t</span> <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a76afb244cc53b394e777ba395d49d88e">write</a>(uint8_t c)<span class="keyword"> override </span>{ <span class="keywordflow">return</span> <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a76afb244cc53b394e777ba395d49d88e">write</a>(&amp;c, 1); }</div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160; </div>
<div class="line"><a name="l00149"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#ae40a4412da47c2be0e4ce81d4924d622">  149</a></span>&#160;  <span class="keyword">virtual</span> <span class="keywordtype">size_t</span> <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#ae40a4412da47c2be0e4ce81d4924d622">write</a>(<span class="keyword">const</span> uint8_t *data, <span class="keywordtype">size_t</span> len) {</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;    <span class="keywordtype">int</span> result = parser.write(data, len);</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;    <span class="comment">// Parse and process the next event</span></div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;    <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a92f154462e857a862484e97e06dd5f61">parse</a>(20);</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;    <span class="keywordflow">return</span> result;</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;  }</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160; </div>
<div class="line"><a name="l00157"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#a7704b4c48c7a8a3fc73d871e8b1f9fe6">  157</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a7704b4c48c7a8a3fc73d871e8b1f9fe6">availableForWrite</a>() { <span class="keywordflow">return</span> parser.<a class="code" href="classmidi_1_1MidiFileParser.html#a1046f0985de526640c1ddaaebfcff943">availableForWrite</a>(); }</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160; </div>
<div class="line"><a name="l00160"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#a7ff602273e17b62b8c9c6cbe126ae495">  160</a></span>&#160;  <span class="keywordtype">int</span> <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a7ff602273e17b62b8c9c6cbe126ae495">trackCount</a>() { <span class="keywordflow">return</span> data.<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#adc37815ca340a51bdba2cff65139dc20">trackCount</a>(); }</div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160; </div>
<div class="line"><a name="l00163"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#a92f154462e857a862484e97e06dd5f61">  163</a></span>&#160;  <a class="code" href="structmidi_1_1midi__parser__state.html">midi_parser_state</a> &amp;<a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a92f154462e857a862484e97e06dd5f61">parse</a>() {</div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;    <span class="comment">// we wait for the parser to complete the processing</span></div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;    <a class="code" href="structmidi_1_1midi__time__event.html">midi_time_event</a> &amp;<span class="keyword">event</span> = <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a980461481f88e7d62c8ee6e531938ab1">parseTimeEvent</a>();</div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;    <span class="keywordflow">if</span> (event == data.<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#aa0208bedf8eabeab38747a41e94fc29b">getNoDataEvent</a>()) {</div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;      <span class="keywordflow">switch</span> (data.<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a36e682a113fbf286e3833c1b33aba26d">status</a>()) {</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;      <span class="keywordflow">case</span> Inserting:</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;        <span class="keywordflow">return</span> not_ready;</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;      <span class="keywordflow">case</span> EndOfData:</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;        <span class="keywordflow">return</span> eob;</div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;      <span class="keywordflow">default</span>:</div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;        <span class="keywordflow">return</span> not_ready;</div>
<div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;      }</div>
<div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;    }</div>
<div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160; </div>
<div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;    <span class="comment">// provide next element</span></div>
<div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;    parser_state.status = MIDI_PARSER_TRACK_MIDI;</div>
<div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;    parser_state.vtime_ms = <span class="keyword">event</span>.time_ms;</div>
<div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;    parser_state.midi.channel = <span class="keyword">event</span>.channel;</div>
<div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;    parser_state.midi.status = <span class="keyword">event</span>.status;</div>
<div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;    parser_state.midi.param1 = <span class="keyword">event</span>.param1;</div>
<div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;    parser_state.midi.param2 = <span class="keyword">event</span>.param2;</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;    <span class="keywordflow">return</span> parser_state;</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;  }</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160; </div>
<div class="line"><a name="l00188"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#aa915f8f2c18d9770debd991a6b33a6d1">  188</a></span>&#160;  <a class="code" href="structmidi_1_1midi__parser__state.html">midi_parser_state</a> &amp;<a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#aa915f8f2c18d9770debd991a6b33a6d1">parseTimed</a>() {</div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160; </div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;    <span class="keywordflow">if</span> (p_current_state == <span class="keyword">nullptr</span>) {</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;      p_current_state = &amp;<a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a980461481f88e7d62c8ee6e531938ab1">parseTimeEvent</a>();</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;    }</div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160; </div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;    <span class="comment">// check if data is relevant</span></div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;    <span class="keywordflow">if</span> (p_current_state == &amp;data.<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#aa0208bedf8eabeab38747a41e94fc29b">getNoDataEvent</a>()) {</div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;      <span class="keywordflow">switch</span> (data.<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a36e682a113fbf286e3833c1b33aba26d">status</a>()) {</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;      <span class="keywordflow">case</span> Inserting:</div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;        p_current_state = <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;        <span class="keywordflow">return</span> not_ready;</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;      <span class="keywordflow">case</span> EndOfData:</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;        <span class="keywordflow">return</span> eob;</div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;      <span class="keywordflow">default</span>:</div>
<div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;        <span class="keywordflow">break</span>;</div>
<div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;      }</div>
<div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;    }</div>
<div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160; </div>
<div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;    <span class="comment">// Wait for event to become relevant</span></div>
<div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;    <span class="keywordflow">if</span> ((millis() - start_time) &lt; p_current_state-&gt;<a class="code" href="structmidi_1_1midi__time__event.html#ae9af222fd26b593eb273897deda503f6">time_ms</a>) {</div>
<div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;      <span class="keywordflow">return</span> not_ready;</div>
<div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;    }</div>
<div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160; </div>
<div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;    <span class="comment">// return result</span></div>
<div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;    parser_state.status = MIDI_PARSER_TRACK_MIDI;</div>
<div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;    parser_state.vtime_ms = p_current_state-&gt;<a class="code" href="structmidi_1_1midi__time__event.html#ae9af222fd26b593eb273897deda503f6">time_ms</a>;</div>
<div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;    parser_state.midi.channel = p_current_state-&gt;channel;</div>
<div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;    parser_state.midi.status = p_current_state-&gt;status;</div>
<div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;    parser_state.midi.param1 = p_current_state-&gt;param1;</div>
<div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;    parser_state.midi.param2 = p_current_state-&gt;param2;</div>
<div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;    p_current_state = <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;    <span class="keywordflow">return</span> parser_state;</div>
<div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;  }</div>
<div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160; </div>
<div class="line"><a name="l00224"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#a16dfda042379f14ce148a878ec478013">  224</a></span>&#160;  <span class="keyword">operator</span> bool() { <span class="keywordflow">return</span> parser || data.<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a36e682a113fbf286e3833c1b33aba26d">status</a>() == Parsing; }</div>
<div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160; </div>
<div class="line"><a name="l00227"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#a73b9a31c1e5e3253b09a8540f5e668e3">  227</a></span>&#160;  <span class="keywordtype">bool</span> <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a73b9a31c1e5e3253b09a8540f5e668e3">isEmpty</a>() { <span class="keywordflow">return</span> data.<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a885bc5c9546339e4c60d74c6c4f9ac56">isEmpty</a>(); }</div>
<div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160; </div>
<div class="line"><a name="l00230"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#a5a55db605490bea7e9d93492459204d5">  230</a></span>&#160;  <span class="keywordtype">size_t</span> <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a5a55db605490bea7e9d93492459204d5">size</a>() { <span class="keywordflow">return</span> data.<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a61c06ef313591f12494db1e1b81748a1">size</a>(); }</div>
<div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160; </div>
<div class="line"><a name="l00233"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#ad98d0a996d0d73927651d46e03cdc04d">  233</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#ad98d0a996d0d73927651d46e03cdc04d">end</a>() { data.<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a0862757999f906a2bfd71881257747a8">end</a>(); }</div>
<div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160; </div>
<div class="line"><a name="l00237"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#aae547b0ac886009072ef71c3394b5a31">  237</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#aae547b0ac886009072ef71c3394b5a31">endWrite</a>() { parser.setState(MIDI_PARSER_EOB); }</div>
<div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160; </div>
<div class="line"><a name="l00240"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#a6a61499a2a04dac517a176dffd5c06de">  240</a></span>&#160;  <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a6a61499a2a04dac517a176dffd5c06de">midi_status_name</a>(<span class="keywordtype">int</span> status) {</div>
<div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;    <span class="keywordflow">return</span> parser.<a class="code" href="classmidi_1_1MidiFileParser.html#a6a310bc896190fd0166e06e08eea6dd5">midi_status_name</a>(status);</div>
<div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;  }</div>
<div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160; </div>
<div class="line"><a name="l00245"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#aa0f717fc245fcc4409b0e18ab07ab145">  245</a></span>&#160;  <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#aa0f717fc245fcc4409b0e18ab07ab145">midi_file_format_name</a>(<span class="keywordtype">int</span> fmt) {</div>
<div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;    <span class="keywordflow">return</span> parser.<a class="code" href="classmidi_1_1MidiFileParser.html#a810b3ac596ac34dddc2f63b902e6b3ad">midi_file_format_name</a>(fmt);</div>
<div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;  }</div>
<div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160; </div>
<div class="line"><a name="l00250"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#ae1f01874aea1a37600d7cdb1ee87e260">  250</a></span>&#160;  <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#ae1f01874aea1a37600d7cdb1ee87e260">midi_meta_name</a>(<span class="keywordtype">int</span> type) { <span class="keywordflow">return</span> parser.<a class="code" href="classmidi_1_1MidiFileParser.html#a2889997844f7c448badf62c33bc5d17e">midi_meta_name</a>(type); }</div>
<div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160; </div>
<div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;<span class="keyword">protected</span>:</div>
<div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;  <a class="code" href="classmidi_1_1MidiFileParser.html">MidiFileParser</a> parser;</div>
<div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;  <a class="code" href="classmidi_1_1multichannel__segment__tracks.html">multichannel_segment_tracks</a> data;</div>
<div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;  <a class="code" href="structmidi_1_1midi__parser__state.html">midi_parser_state</a> parser_state;</div>
<div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;  <a class="code" href="structmidi_1_1midi__parser__state.html">midi_parser_state</a> not_ready{MIDI_PARSER_DELAY};</div>
<div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;  midi_parser_state eob{MIDI_PARSER_EOB};</div>
<div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;  midi_time_event *p_current_state = <span class="keyword">nullptr</span>;</div>
<div class="line"><a name="l00259"></a><span class="lineno">  259</span>&#160;  uint64_t start_time = 0l;</div>
<div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;  <span class="keywordtype">bool</span> is_iterators_available = <span class="keyword">false</span>;</div>
<div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160; </div>
<div class="line"><a name="l00262"></a><span class="lineno">  262</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a92f154462e857a862484e97e06dd5f61">parse</a>(<span class="keywordtype">int</span> limit) {</div>
<div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;    <span class="keywordflow">while</span> (parser.parser_state.in.available() &gt; limit) {</div>
<div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;      midi_parser_state &amp;state = parser.<a class="code" href="classmidi_1_1MidiFileParser.html#a0c4097975bcf7c4a1d19c377943bf227">parse</a>();</div>
<div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;      <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#aa9f3a4051501b93e63873e9de460f50f">addEvent</a>(state);</div>
<div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;    }</div>
<div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;  }</div>
<div class="line"><a name="l00268"></a><span class="lineno">  268</span>&#160; </div>
<div class="line"><a name="l00270"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#aa9f3a4051501b93e63873e9de460f50f">  270</a></span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#aa9f3a4051501b93e63873e9de460f50f">addEvent</a>(<a class="code" href="structmidi_1_1midi__parser__state.html">midi_parser_state</a> &amp;state) {</div>
<div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;    <span class="keywordtype">int</span> track = state.track.number;</div>
<div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;    <span class="comment">// add new midi_time_event</span></div>
<div class="line"><a name="l00273"></a><span class="lineno">  273</span>&#160;    <a class="code" href="structmidi_1_1midi__time__event.html">midi_time_event</a> event;</div>
<div class="line"><a name="l00274"></a><span class="lineno">  274</span>&#160;    <span class="keyword">event</span>.status = state.midi.status;</div>
<div class="line"><a name="l00275"></a><span class="lineno">  275</span>&#160;    <span class="keyword">event</span>.channel = state.midi.channel;</div>
<div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160;    <span class="keyword">event</span>.param1 = state.midi.param1;</div>
<div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;    <span class="keyword">event</span>.param2 = state.midi.param2;</div>
<div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;    <span class="keyword">event</span>.time_ms = state.timeInMs() + data.<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#afd3ff3d9ec131ac20c6c0c5ce46a777a">lastTime</a>(track);</div>
<div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;    data.<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a119d4fc00378871d2bef72a88a572935">add</a>(track, event);</div>
<div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;    </div>
<div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;  }</div>
<div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160; </div>
<div class="line"><a name="l00284"></a><span class="lineno"><a class="line" href="classmidi_1_1MidiFileParserMultiTrack.html#a980461481f88e7d62c8ee6e531938ab1">  284</a></span>&#160;  <a class="code" href="structmidi_1_1midi__time__event.html">midi_time_event</a> &amp;<a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a980461481f88e7d62c8ee6e531938ab1">parseTimeEvent</a>() {</div>
<div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;    <span class="comment">// create iterators to point at beginning</span></div>
<div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;    <span class="keywordflow">if</span> (!is_iterators_available) {</div>
<div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;      <span class="comment">// complete parsing</span></div>
<div class="line"><a name="l00288"></a><span class="lineno">  288</span>&#160;      <a class="code" href="classmidi_1_1MidiFileParserMultiTrack.html#a92f154462e857a862484e97e06dd5f61">parse</a>(0);</div>
<div class="line"><a name="l00289"></a><span class="lineno">  289</span>&#160;      <span class="comment">// setup iterators</span></div>
<div class="line"><a name="l00290"></a><span class="lineno">  290</span>&#160;      is_iterators_available = <span class="keyword">true</span>;</div>
<div class="line"><a name="l00291"></a><span class="lineno">  291</span>&#160;      data.<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#a79722815460ae3f98162837e93adcfc6">begin</a>();</div>
<div class="line"><a name="l00292"></a><span class="lineno">  292</span>&#160;    }</div>
<div class="line"><a name="l00293"></a><span class="lineno">  293</span>&#160; </div>
<div class="line"><a name="l00294"></a><span class="lineno">  294</span>&#160;    <span class="comment">// provide next element</span></div>
<div class="line"><a name="l00295"></a><span class="lineno">  295</span>&#160;    <span class="keywordflow">return</span> data.<a class="code" href="classmidi_1_1multichannel__segment__tracks.html#abd2d16ad792d4d417abacfadb167d56b">nextEvent</a>();</div>
<div class="line"><a name="l00296"></a><span class="lineno">  296</span>&#160;  }</div>
<div class="line"><a name="l00297"></a><span class="lineno">  297</span>&#160;};</div>
<div class="line"><a name="l00298"></a><span class="lineno">  298</span>&#160; </div>
<div class="line"><a name="l00299"></a><span class="lineno">  299</span>&#160;} <span class="comment">// namespace midi</span></div>
<div class="ttc" id="aMidiFileParser_8h_html"><div class="ttname"><a href="MidiFileParser_8h.html">MidiFileParser.h</a></div><div class="ttdoc">A simple midi parser based on the following project https://github.com/abique/midi-parser.</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html">midi::MidiFileParserMultiTrack</a></div><div class="ttdoc">Midi file parser which stores the data in RAM before making them available for parsing....</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:130</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_a5a55db605490bea7e9d93492459204d5"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#a5a55db605490bea7e9d93492459204d5">midi::MidiFileParserMultiTrack::size</a></div><div class="ttdeci">size_t size()</div><div class="ttdoc">Returns the number of available midi events (after writing)</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:230</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_a6a61499a2a04dac517a176dffd5c06de"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#a6a61499a2a04dac517a176dffd5c06de">midi::MidiFileParserMultiTrack::midi_status_name</a></div><div class="ttdeci">const char * midi_status_name(int status)</div><div class="ttdoc">Provides the string description for the midi_status value.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:240</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_a73b9a31c1e5e3253b09a8540f5e668e3"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#a73b9a31c1e5e3253b09a8540f5e668e3">midi::MidiFileParserMultiTrack::isEmpty</a></div><div class="ttdeci">bool isEmpty()</div><div class="ttdoc">Returns true if there are no midi events.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:227</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_a76afb244cc53b394e777ba395d49d88e"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#a76afb244cc53b394e777ba395d49d88e">midi::MidiFileParserMultiTrack::write</a></div><div class="ttdeci">size_t write(uint8_t c) override</div><div class="ttdoc">Single character write.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:146</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_a7704b4c48c7a8a3fc73d871e8b1f9fe6"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#a7704b4c48c7a8a3fc73d871e8b1f9fe6">midi::MidiFileParserMultiTrack::availableForWrite</a></div><div class="ttdeci">int availableForWrite()</div><div class="ttdoc">Max number of bytes that we can write.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:157</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_a7ff602273e17b62b8c9c6cbe126ae495"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#a7ff602273e17b62b8c9c6cbe126ae495">midi::MidiFileParserMultiTrack::trackCount</a></div><div class="ttdeci">int trackCount()</div><div class="ttdoc">Returns the number of recorded tracks.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:160</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_a92f154462e857a862484e97e06dd5f61"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#a92f154462e857a862484e97e06dd5f61">midi::MidiFileParserMultiTrack::parse</a></div><div class="ttdeci">midi_parser_state &amp; parse()</div><div class="ttdoc">Provide the next midi element.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:163</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_a980461481f88e7d62c8ee6e531938ab1"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#a980461481f88e7d62c8ee6e531938ab1">midi::MidiFileParserMultiTrack::parseTimeEvent</a></div><div class="ttdeci">midi_time_event &amp; parseTimeEvent()</div><div class="ttdoc">Provide the next midi element using the iterators.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:284</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_aa0f717fc245fcc4409b0e18ab07ab145"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#aa0f717fc245fcc4409b0e18ab07ab145">midi::MidiFileParserMultiTrack::midi_file_format_name</a></div><div class="ttdeci">const char * midi_file_format_name(int fmt)</div><div class="ttdoc">Provides the string description for the file format.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:245</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_aa915f8f2c18d9770debd991a6b33a6d1"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#aa915f8f2c18d9770debd991a6b33a6d1">midi::MidiFileParserMultiTrack::parseTimed</a></div><div class="ttdeci">midi_parser_state &amp; parseTimed()</div><div class="ttdoc">Provide the next midi element considering the times.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:188</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_aa9f3a4051501b93e63873e9de460f50f"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#aa9f3a4051501b93e63873e9de460f50f">midi::MidiFileParserMultiTrack::addEvent</a></div><div class="ttdeci">void addEvent(midi_parser_state &amp;state)</div><div class="ttdoc">Adds an new midi event with the corresponding time.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:270</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_aae547b0ac886009072ef71c3394b5a31"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#aae547b0ac886009072ef71c3394b5a31">midi::MidiFileParserMultiTrack::endWrite</a></div><div class="ttdeci">void endWrite()</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:237</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_ad98d0a996d0d73927651d46e03cdc04d"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#ad98d0a996d0d73927651d46e03cdc04d">midi::MidiFileParserMultiTrack::end</a></div><div class="ttdeci">void end()</div><div class="ttdoc">Ends the processing: releases all memory.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:233</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_ae1f01874aea1a37600d7cdb1ee87e260"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#ae1f01874aea1a37600d7cdb1ee87e260">midi::MidiFileParserMultiTrack::midi_meta_name</a></div><div class="ttdeci">const char * midi_meta_name(int type)</div><div class="ttdoc">Provides the string description for the midi_meta value.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:250</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_ae40a4412da47c2be0e4ce81d4924d622"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#ae40a4412da47c2be0e4ce81d4924d622">midi::MidiFileParserMultiTrack::write</a></div><div class="ttdeci">virtual size_t write(const uint8_t *data, size_t len)</div><div class="ttdoc">Feed/Provide the midi data to the parser.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:149</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_af23129775e877eed69220c3709562d86"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#af23129775e877eed69220c3709562d86">midi::MidiFileParserMultiTrack::restart</a></div><div class="ttdeci">void restart()</div><div class="ttdoc">Call this method to restart the parsing with the available data.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:139</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParserMultiTrack_html_af71bf056c87c4b20f92e61f1864c0fda"><div class="ttname"><a href="classmidi_1_1MidiFileParserMultiTrack.html#af71bf056c87c4b20f92e61f1864c0fda">midi::MidiFileParserMultiTrack::begin</a></div><div class="ttdeci">bool begin(bool log=true, int bufferSize=MIDI_BUFFER_SIZE)</div><div class="ttdoc">Initializes &amp; starts the processing.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:133</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParser_html"><div class="ttname"><a href="classmidi_1_1MidiFileParser.html">midi::MidiFileParser</a></div><div class="ttdoc">Midi File parser. Provide the data via write: You should try to keep the buffer as full as possible w...</div><div class="ttdef"><b>Definition:</b> MidiFileParser.h:61</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParser_html_a0c4097975bcf7c4a1d19c377943bf227"><div class="ttname"><a href="classmidi_1_1MidiFileParser.html#a0c4097975bcf7c4a1d19c377943bf227">midi::MidiFileParser::parse</a></div><div class="ttdeci">midi_parser_state &amp; parse()</div><div class="ttdoc">Parse data in order to provide the next midi element.</div><div class="ttdef"><b>Definition:</b> MidiFileParser.h:92</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParser_html_a1046f0985de526640c1ddaaebfcff943"><div class="ttname"><a href="classmidi_1_1MidiFileParser.html#a1046f0985de526640c1ddaaebfcff943">midi::MidiFileParser::availableForWrite</a></div><div class="ttdeci">int availableForWrite()</div><div class="ttdoc">Max number of bytes that we can write.</div><div class="ttdef"><b>Definition:</b> MidiFileParser.h:89</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParser_html_a2889997844f7c448badf62c33bc5d17e"><div class="ttname"><a href="classmidi_1_1MidiFileParser.html#a2889997844f7c448badf62c33bc5d17e">midi::MidiFileParser::midi_meta_name</a></div><div class="ttdeci">const char * midi_meta_name(int type)</div><div class="ttdoc">Provides the string description for the midi_meta value.</div><div class="ttdef"><b>Definition:</b> MidiFileParser.h:191</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParser_html_a6a310bc896190fd0166e06e08eea6dd5"><div class="ttname"><a href="classmidi_1_1MidiFileParser.html#a6a310bc896190fd0166e06e08eea6dd5">midi::MidiFileParser::midi_status_name</a></div><div class="ttdeci">const char * midi_status_name(int status)</div><div class="ttdoc">Provides the string description for the midi_status value.</div><div class="ttdef"><b>Definition:</b> MidiFileParser.h:153</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParser_html_a810b3ac596ac34dddc2f63b902e6b3ad"><div class="ttname"><a href="classmidi_1_1MidiFileParser.html#a810b3ac596ac34dddc2f63b902e6b3ad">midi::MidiFileParser::midi_file_format_name</a></div><div class="ttdeci">const char * midi_file_format_name(int fmt)</div><div class="ttdoc">Provides the string description for the file format.</div><div class="ttdef"><b>Definition:</b> MidiFileParser.h:176</div></div>
<div class="ttc" id="aclassmidi_1_1MidiFileParser_html_aabf9f00c6bb20006a33690ce1ae27dd6"><div class="ttname"><a href="classmidi_1_1MidiFileParser.html#aabf9f00c6bb20006a33690ce1ae27dd6">midi::MidiFileParser::begin</a></div><div class="ttdeci">bool begin(bool log=true, int bufferSize=MIDI_BUFFER_SIZE)</div><div class="ttdoc">Initializes &amp; starts the processing.</div><div class="ttdef"><b>Definition:</b> MidiFileParser.h:64</div></div>
<div class="ttc" id="aclassmidi_1_1Print_html"><div class="ttname"><a href="classmidi_1_1Print.html">midi::Print</a></div><div class="ttdef"><b>Definition:</b> MidiFileParser.h:46</div></div>
<div class="ttc" id="aclassmidi_1_1multichannel__segment__tracks_html"><div class="ttname"><a href="classmidi_1_1multichannel__segment__tracks.html">midi::multichannel_segment_tracks</a></div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:15</div></div>
<div class="ttc" id="aclassmidi_1_1multichannel__segment__tracks_html_a0862757999f906a2bfd71881257747a8"><div class="ttname"><a href="classmidi_1_1multichannel__segment__tracks.html#a0862757999f906a2bfd71881257747a8">midi::multichannel_segment_tracks::end</a></div><div class="ttdeci">void end()</div><div class="ttdoc">Releases all data.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:97</div></div>
<div class="ttc" id="aclassmidi_1_1multichannel__segment__tracks_html_a119d4fc00378871d2bef72a88a572935"><div class="ttname"><a href="classmidi_1_1multichannel__segment__tracks.html#a119d4fc00378871d2bef72a88a572935">midi::multichannel_segment_tracks::add</a></div><div class="ttdeci">void add(int track, midi_time_event event)</div><div class="ttdoc">Adds an midi event to the indicated track.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:18</div></div>
<div class="ttc" id="aclassmidi_1_1multichannel__segment__tracks_html_a36e682a113fbf286e3833c1b33aba26d"><div class="ttname"><a href="classmidi_1_1multichannel__segment__tracks.html#a36e682a113fbf286e3833c1b33aba26d">midi::multichannel_segment_tracks::status</a></div><div class="ttdeci">ProcessingStatus status()</div><div class="ttdoc">Provides the current processing status.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:103</div></div>
<div class="ttc" id="aclassmidi_1_1multichannel__segment__tracks_html_a61c06ef313591f12494db1e1b81748a1"><div class="ttname"><a href="classmidi_1_1multichannel__segment__tracks.html#a61c06ef313591f12494db1e1b81748a1">midi::multichannel_segment_tracks::size</a></div><div class="ttdeci">size_t size()</div><div class="ttdoc">Count number for midi events.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:76</div></div>
<div class="ttc" id="aclassmidi_1_1multichannel__segment__tracks_html_a79722815460ae3f98162837e93adcfc6"><div class="ttname"><a href="classmidi_1_1multichannel__segment__tracks.html#a79722815460ae3f98162837e93adcfc6">midi::multichannel_segment_tracks::begin</a></div><div class="ttdeci">void begin()</div><div class="ttdoc">Moves the iterators to the first element.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:31</div></div>
<div class="ttc" id="aclassmidi_1_1multichannel__segment__tracks_html_a885bc5c9546339e4c60d74c6c4f9ac56"><div class="ttname"><a href="classmidi_1_1multichannel__segment__tracks.html#a885bc5c9546339e4c60d74c6c4f9ac56">midi::multichannel_segment_tracks::isEmpty</a></div><div class="ttdeci">bool isEmpty()</div><div class="ttdoc">Returns true if there are no midi events.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:85</div></div>
<div class="ttc" id="aclassmidi_1_1multichannel__segment__tracks_html_aa0208bedf8eabeab38747a41e94fc29b"><div class="ttname"><a href="classmidi_1_1multichannel__segment__tracks.html#aa0208bedf8eabeab38747a41e94fc29b">midi::multichannel_segment_tracks::getNoDataEvent</a></div><div class="ttdeci">midi_time_event &amp; getNoDataEvent()</div><div class="ttdoc">Provides the reference to the nodata time event which signals that we provided no data.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:106</div></div>
<div class="ttc" id="aclassmidi_1_1multichannel__segment__tracks_html_abd2d16ad792d4d417abacfadb167d56b"><div class="ttname"><a href="classmidi_1_1multichannel__segment__tracks.html#abd2d16ad792d4d417abacfadb167d56b">midi::multichannel_segment_tracks::nextEvent</a></div><div class="ttdeci">midi_time_event &amp; nextEvent()</div><div class="ttdoc">Provides the next event.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:48</div></div>
<div class="ttc" id="aclassmidi_1_1multichannel__segment__tracks_html_adc37815ca340a51bdba2cff65139dc20"><div class="ttname"><a href="classmidi_1_1multichannel__segment__tracks.html#adc37815ca340a51bdba2cff65139dc20">midi::multichannel_segment_tracks::trackCount</a></div><div class="ttdeci">int trackCount()</div><div class="ttdoc">Provides the number of tracks.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:28</div></div>
<div class="ttc" id="aclassmidi_1_1multichannel__segment__tracks_html_afd3ff3d9ec131ac20c6c0c5ce46a777a"><div class="ttname"><a href="classmidi_1_1multichannel__segment__tracks.html#afd3ff3d9ec131ac20c6c0c5ce46a777a">midi::multichannel_segment_tracks::lastTime</a></div><div class="ttdeci">uint64_t lastTime(int track)</div><div class="ttdoc">Provides the last recorded time for the indicated track.</div><div class="ttdef"><b>Definition:</b> MidiFileParserMultiTrack.h:88</div></div>
<div class="ttc" id="astructmidi_1_1midi__parser__state_html"><div class="ttname"><a href="structmidi_1_1midi__parser__state.html">midi::midi_parser_state</a></div><div class="ttdoc">MIDI Parser State Information.</div><div class="ttdef"><b>Definition:</b> MidiFileParserState.h:119</div></div>
<div class="ttc" id="astructmidi_1_1midi__time__event_html"><div class="ttname"><a href="structmidi_1_1midi__time__event.html">midi::midi_time_event</a></div><div class="ttdef"><b>Definition:</b> MidiFileParserState.h:90</div></div>
<div class="ttc" id="astructmidi_1_1midi__time__event_html_ae9af222fd26b593eb273897deda503f6"><div class="ttname"><a href="structmidi_1_1midi__time__event.html#ae9af222fd26b593eb273897deda503f6">midi::midi_time_event::time_ms</a></div><div class="ttdeci">uint64_t time_ms</div><div class="ttdoc">cummulated time in milliseconds</div><div class="ttdef"><b>Definition:</b> MidiFileParserState.h:92</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>
